{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Python program to  Edge detection  \n",
    "# using OpenCV in Python \n",
    "import cv2 \n",
    "import numpy as np \n",
    "import matplotlib.pyplot as plt \n",
    "  \n",
    "# reading input image\n",
    "img = cv2.imread('foggy-5.jpg') \n",
    "\n",
    "# Convert to HSV for simpler calculations \n",
    "hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) \n",
    "\n",
    "# define range of red color in HSV \n",
    "lower_red = np.array([30,150,50]) \n",
    "upper_red = np.array([255,255,180]) \n",
    "\n",
    "# create a red HSV colour boundary and  \n",
    "# threshold HSV image \n",
    "mask = cv2.inRange(hsv, lower_red, upper_red)\n",
    "\n",
    "# Bitwise-AND mask and original image \n",
    "res = cv2.bitwise_and(img,img, mask= mask) \n",
    "\n",
    "# Display an original image \n",
    "cv2.imshow('Original',img) \n",
    "\n",
    "# finds edges in the input image image and \n",
    "# marks them in the output map edges \n",
    "edges = cv2.Canny(img,100,200) \n",
    "\n",
    "# Display edges in a frame \n",
    "cv2.imshow('Edges',edges)\n",
    "cv2.waitKey(0) \n",
    "  \n",
    "cv2.destroyAllWindows() \n",
    "  \n",
    "#release the frame \n",
    "cap.release() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2 \n",
    "import numpy as np \n",
    "import matplotlib.pyplot as plt \n",
    "  \n",
    "# reading input image\n",
    "img = cv2.imread('151028122617-indonesia-haze-1027-01-super-169.jpg') \n",
    "\n",
    "edges = cv2.Canny(img,10,150)\n",
    "\n",
    "# plt.subplot(121),plt.imshow(img,cmap = 'gray')\n",
    "# plt.title('Original Image'), plt.xticks([]), plt.yticks([])\n",
    "# plt.subplot(122),plt.imshow(edges,cmap = 'gray')\n",
    "# plt.title('Edge Image'), plt.xticks([]), plt.yticks([])\n",
    "\n",
    "# plt.show()\n",
    "\n",
    "cv2.imshow('image',img)\n",
    "cv2.imshow('edges',edges)\n",
    "k = cv2.waitKey(0) & 0xFF\n",
    "  \n",
    "# wait for ESC key to exit \n",
    "if k == 27:  \n",
    "    cv2.destroyAllWindows() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
